#include <SDL.h>
int menu(SDL_Surface *screen)
{
    SDL_Event event;

    int one=0,i=0;


    // load an image
    SDL_Surface* mp1 = SDL_LoadBMP("img/2.bmp");


    if (!mp1)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());
        return 1;
    }
    SDL_Surface *mp2 = SDL_LoadBMP("img/3.bmp");
    if (mp2 == NULL)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());
        return 1;
    }
     SDL_Surface *mp3 = SDL_LoadBMP("img/4.bmp");
    if (mp3 == NULL)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());
        return 1;
    }
 SDL_Surface *mp4 = SDL_LoadBMP("img/5.bmp");
    if (mp4 == NULL)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());
        return 1;
    }
 SDL_Surface *mp5 = SDL_LoadBMP("img/6.bmp");
    if (mp5 == NULL)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());
        return 1;
    }




    // centre the bitmap on screen



    // program main loop

    SDL_EnableKeyRepeat(100,100);

    while (!one)
    {
        // message processing loop
        while (SDL_PollEvent(&event))
        {
            // check for messages
            switch (event.type)
            {
                // exit if the window is closed
            case SDL_QUIT:
                one = 1;
                break;

                // check for keypresses
            case SDL_KEYDOWN:
            {
                // exit if ESCAPE is pressed
                switch (event.key.keysym.sym)
                {

                case  SDLK_ESCAPE:
                    one=1;
                    break;
                case SDLK_UP:
                        i--;

                    break;
                case SDLK_DOWN:
                        i++;
                    break;
                case SDLK_RETURN:
                   { if(i==0)
                    return(1);
                  else  if(i==3)
                   return(4);
                   else if(i==4)
                   return(5);
            }
                    break;


                } // end main loop

            }

            }

         if(i==0)
        SDL_BlitSurface(mp1, NULL, screen, NULL);
         if(i==1)
        SDL_BlitSurface(mp2, NULL, screen, NULL);
         if(i==2)
        SDL_BlitSurface(mp3, NULL, screen, NULL);
         if(i==3)
        SDL_BlitSurface(mp4, NULL, screen, NULL);
         if(i==4)
        SDL_BlitSurface(mp5, NULL, screen, NULL);


                  SDL_Flip(screen);


         i=i%5;




        }


        SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
  SDL_BlitSurface(mp1, NULL, screen, NULL);

    }

SDL_FreeSurface(screen);
SDL_FreeSurface(mp1);
SDL_FreeSurface(mp2);
SDL_FreeSurface(mp3);
SDL_FreeSurface(mp4);
SDL_FreeSurface(mp5);




 }


